#===============================================================================
#                             JSON Iterators
#===============================================================================
def jsonitems(obj, jsonlevel=1):
    '''
    Similar to iteritems, but it prevents iteration over strings and imposes
    conformation to the JSON standard using the jsonlevel attribute.
    
    Observations
    ------------
    
    JSON structures have values stored in container objects. Python strings 
    behave like container objects (a sequence of chars), but they should not be 
    treated as containers in JSON. 
    
    This special treatment is required in order to avoid an infinite expansion 
    when iterating over a JSON-like structure. A container object is interpreted
    either as a JSON Object (or Python dict) or as a JSON Array (Python list). 
    Since strings respect the sequence interface, they would be treated as 
    Arrays, and  would be expanded into a Python list, e.g.,
    
        'foo' -> ['f', 'o', 'o']

    But each character in ['f', 'o', 'o'] is also a string and they would be 
    expanded like 'f' -> ['f'] -> [['f']] -> ...; this infinite expansion is
    obviously not desired.  
    '''

    raise NotImplemented



if __name__ == '__main__':
    import doctest
    doctest.testmod(optionflags=doctest.REPORT_ONLY_FIRST_FAILURE, verbose=0)
    print 'OK'
